<template>
  <div class="tab-content-wrap">
    <u-page-config
      :filter-array="filterArray"
      v-model="filter"
      :getList="getList"
      :tableData="tableData"
      :tableColumn="tableColumn"
      :total="total"
      :loading="loading"
      :showTool="false"
      @transWorkOrder="transWorkOrder"
    >

      <template #equipmentFalutType="{row, item}">
        {{ getDictLabel(item.options, row.equipmentFalutType) }}
      </template>
    </u-page-config>

    <add-work-order-dialog
      v-model="visible"
      mode="form"
      :device-data="form"
      isFaultLogUse
    />
  </div>
</template>

<script>
import UPageConfig from '@/components/uPageConfig/index'
import table from "@/mixin/uTable";
import {listFaultLog} from "@/api/monitor/equipmentFault";
import AddWorkOrderDialog from '@/views/operationAndMonitoring/workerOrder/components/addWorkOrderDialog'

export default {
  name: "modelInfo",
  mixins: [table],
  components: {UPageConfig, AddWorkOrderDialog},
  props: {
    // 模块列表
    deviceId: {
      type: String,
      default: ''
    },
    // 设备部署信息
    deviceDeploymentInfo: {
      type: Object,
      default() {
        return {}
      }
    },
  },
  data() {
    return {
      tableData: [],
      filterArray: [
        {
          label: "设备状态", key: "equipmentFalutType", type: "select", options: [
            {value: null, label: "全部"},
            {value: "0", label: "运行中上报"},
            {value: "1", label: "人工上报"},
            {value: "2", label: "开机自检上报"},
          ]
        },
      ],
      tableColumn: [
        {label: "id", prop: "id"},
        {label: "生成时间", prop: "createTime", type: 'time'},
        {
          label: "异常类型", prop: "equipmentFalutType", type: 'slot',
          options: [
            {label: "运行中上报", value: "0"},
            {label: "人工上报", value: "1"},
            {label: "开机自检上报", value: "2"},
          ]
        },
        {label: "异常编码", prop: "errorCode"},
        {label: "异常内容", prop: "errorMessage"},
        {label: "故障图片", prop: "image", type: 'image'},
        {
          label: "操作", type: "btn", attr: {width: 180}, btnArr: [
            {
              icon: "el-icon-s-order", text: "转工单", emit: "transWorkOrder",
              permissions: 'operationAndMonitoring:deviceMonitoring:addWorkOrder',
            },
          ]
        },
      ],
      form: {}
    }
  },
  methods: {
    /** 查询设备模块列表 */
    getList() {
      this.getInit(listFaultLog, {
        deviceId: this.deviceId
      })
    },
    transWorkOrder(row) {
      this.visible = true;
      this.form = JSON.parse(JSON.stringify(row));
    }
  }
}
</script>
